<?php 


require '../dao/gongaodao.php';
session_start();
$gongaoid=$_GET['gongaoid'];//获取到要查询的公告的id
//$gongao=$_GET['gongao'];//获取到要增加的公告的内容
$delid=$_GET['delid'];//获取到要删除的公告的id
$dao=new gongaodao();
$gongaodel=$dao->Del($delid);//删除公告
$gongaolist=$dao->Chaxun($gongaoid);//查询id

//print  $gongaodel;
if(empty($gongaolist)) {
	$info="公告不存在";
}
if(empty($_POST['gongao'])){
	$infoo= "请输入";
}
?>
<form action="../controller/handout.php?con=gongao&action=gongaoquery" method="post">
<label>公告id：</label>
<input type="text" name="gongaoid"/>
<input type="submit"  value="查询"/>
</form>

<table class="tab">
<tr>
	<td>公告ID</td>
	<td>公告内容</td>
	<td>图片</td>
	<td>发表时间</td>
	<td>删除公告</td>
</tr>
 <?php foreach ($gongaolist as $gamer){ ?>
 <tr>
	<?php foreach ($gamer as $i=>$value){
	if($value=="del"){?>
       <td><a href="main.php?url=gongao.php&delid=<?php echo $gamer['id']?>">删除</a></td>    
	<?php }
	 else {  ?><td><?php 
if ($i=='img'){
if(strpos($value, "/")!=false){
echo "<img src='../../qian/".$value."'/>";
}else
echo "<img src='../view/img.php?src=".$value."'/>";
}
   else {echo $value; }	
	}?></td>
	<?php } ?>
</tr>
<?php }?>


</table>
<form  action="../controller/handout.php?con=gongao&action=gongaotian" enctype="multipart/form-data" method="post">
<label>添加公告：</label>
<textarea name="gongao" rows="5" cols="20"></textarea>
<input type="submit"  value="添加"/>
<input type="file" name="file"  value="上传图片"/> 
</form>
<?php  if(!empty($infoo)){echo $infoo;}
?>